//
//  NSData+Socket.m
//  高仿暴走斗图
//
//  Created by key on 16/4/1.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "NSData+Socket.h"
#import "NSObject+Json.h"

@implementation NSData (Socket)

+ (NSData *)convertSocketInfoToDataWithJSONModel:(HSYSocketDataJSONModel *)jsonModel {
    
    if (!jsonModel) {
        return nil;
    }
    
    NSDictionary *dictionary = [jsonModel toDictionary];
    
    NSString *dataString = [NSObject convertJsonToStringFromJSONObject:dictionary];
    dataString = [dataString stringByAppendingString:@"\n"];                        //json数据以换行符\n作为结束点
    NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
    
    return data;
}

@end
